﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using MiniFox.Data.EntityFramework;
using MiniFox.Data.EntityFramework.MySql;

namespace Dispatcher.Data.Entities.MySql;

public partial class DispatcherContext : MySqlDbContext
{
    public DispatcherContext(DbContextOptions<DispatcherContext> options)
        : base("DispatcherContext", options)
    {
    }

    public virtual DbSet<DingtalkSent> DingtalkSent { get; set; }

    public virtual DbSet<File> File { get; set; }

    public virtual DbSet<MailSent> MailSent { get; set; }

    public virtual DbSet<MailSentFail> MailSentFail { get; set; }

    public virtual DbSet<MessageAttachment> MessageAttachment { get; set; }

    public virtual DbSet<MessageRecv> MessageRecv { get; set; }

    public virtual DbSet<MessageSent> MessageSent { get; set; }

    public virtual DbSet<WechatSent> WechatSent { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder
            .UseCollation("utf8mb4_0900_ai_ci")
            .HasCharSet("utf8mb4");

        modelBuilder.Entity<DingtalkSent>(entity =>
        {
            entity.HasKey(e => e.MessageId).HasName("PRIMARY");

            entity.ToTable("dingtalk_sent");

            entity.Property(e => e.MessageId)
                .HasMaxLength(50)
                .HasColumnName("message_id");
            entity.Property(e => e.AccountName)
                .HasMaxLength(50)
                .HasColumnName("account_name");
            entity.Property(e => e.Body).HasColumnName("body");
            entity.Property(e => e.Data).HasColumnName("data");
            entity.Property(e => e.PictureUrl)
                .HasMaxLength(2048)
                .HasColumnName("picture_url");
            entity.Property(e => e.Receiver)
                .HasMaxLength(500)
                .HasColumnName("receiver");
            entity.Property(e => e.Response).HasColumnName("response");
            entity.Property(e => e.Result).HasColumnName("result");
            entity.Property(e => e.SendTime)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("timestamp")
                .HasColumnName("send_time");
            entity.Property(e => e.TaskId)
                .HasMaxLength(50)
                .HasColumnName("task_id");
            entity.Property(e => e.TemplateName)
                .HasMaxLength(50)
                .HasColumnName("template_name");
            entity.Property(e => e.Title)
                .HasMaxLength(100)
                .HasColumnName("title");
            entity.Property(e => e.Url)
                .HasMaxLength(2048)
                .HasColumnName("url");
        });

        modelBuilder.Entity<File>(entity =>
        {
            entity.HasKey(e => e.FileId).HasName("PRIMARY");

            entity.ToTable("file");

            entity.HasIndex(e => new { e.Group, e.Path, e.FileName }, "file_uk").IsUnique();

            entity.Property(e => e.FileId)
                .HasMaxLength(50)
                .HasColumnName("file_id");
            entity.Property(e => e.Accepted).HasColumnName("accepted");
            entity.Property(e => e.ContentLength).HasColumnName("content_length");
            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("timestamp")
                .HasColumnName("create_time");
            entity.Property(e => e.ExtName)
                .HasMaxLength(10)
                .HasColumnName("ext_name");
            entity.Property(e => e.FileName)
                .HasMaxLength(50)
                .HasColumnName("file_name");
            entity.Property(e => e.Group)
                .HasMaxLength(50)
                .HasColumnName("group");
            entity.Property(e => e.MimeType)
                .HasMaxLength(200)
                .HasColumnName("mime_type");
            entity.Property(e => e.Path)
                .HasMaxLength(512)
                .HasComment("目录路径")
                .HasColumnName("path");
            entity.Property(e => e.UpdateTime)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("timestamp")
                .HasColumnName("update_time");
        });

        modelBuilder.Entity<MailSent>(entity =>
        {
            entity.HasKey(e => e.MessageId).HasName("PRIMARY");

            entity.ToTable("mail_sent");

            entity.Property(e => e.MessageId)
                .HasMaxLength(64)
                .HasColumnName("message_id");
            entity.Property(e => e.AccountName)
                .HasMaxLength(50)
                .HasColumnName("account_name");
            entity.Property(e => e.BccList)
                .HasMaxLength(1024)
                .HasColumnName("bcc_list");
            entity.Property(e => e.Body)
                .HasColumnType("text")
                .HasColumnName("body");
            entity.Property(e => e.CcList)
                .HasMaxLength(1024)
                .HasColumnName("cc_list");
            entity.Property(e => e.IsAsync).HasColumnName("is_async");
            entity.Property(e => e.Receiver)
                .HasMaxLength(200)
                .HasColumnName("receiver");
            entity.Property(e => e.SendData)
                .HasColumnType("text")
                .HasColumnName("send_data");
            entity.Property(e => e.SendTime)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("timestamp")
                .HasColumnName("send_time");
            entity.Property(e => e.Sender)
                .HasMaxLength(100)
                .HasColumnName("sender");
            entity.Property(e => e.TemplateName)
                .HasMaxLength(50)
                .HasColumnName("template_name");
            entity.Property(e => e.Title)
                .HasMaxLength(50)
                .HasColumnName("title");
        });

        modelBuilder.Entity<MailSentFail>(entity =>
        {
            entity.HasKey(e => e.MessageId).HasName("PRIMARY");

            entity.ToTable("mail_sent_fail");

            entity.Property(e => e.MessageId)
                .HasMaxLength(64)
                .HasColumnName("message_id");
            entity.Property(e => e.AccountName)
                .HasMaxLength(50)
                .HasColumnName("account_name");
            entity.Property(e => e.BccList)
                .HasMaxLength(1024)
                .HasColumnName("bcc_list");
            entity.Property(e => e.Body)
                .HasColumnType("text")
                .HasColumnName("body");
            entity.Property(e => e.CcList)
                .HasMaxLength(1024)
                .HasColumnName("cc_list");
            entity.Property(e => e.Exception)
                .HasColumnType("text")
                .HasColumnName("exception");
            entity.Property(e => e.IsAsync).HasColumnName("is_async");
            entity.Property(e => e.Receiver)
                .HasMaxLength(200)
                .HasColumnName("receiver");
            entity.Property(e => e.SendData)
                .HasColumnType("text")
                .HasColumnName("send_data");
            entity.Property(e => e.SendTime)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("timestamp")
                .HasColumnName("send_time");
            entity.Property(e => e.Sender)
                .HasMaxLength(100)
                .HasColumnName("sender");
            entity.Property(e => e.TemplateName)
                .HasMaxLength(50)
                .HasColumnName("template_name");
            entity.Property(e => e.Title)
                .HasMaxLength(50)
                .HasColumnName("title");
        });

        modelBuilder.Entity<MessageAttachment>(entity =>
        {
            entity.HasKey(e => e.FileId).HasName("PRIMARY");

            entity.ToTable("message_attachment");

            entity.Property(e => e.FileId)
                .HasMaxLength(50)
                .HasColumnName("file_id");
            entity.Property(e => e.MessageId)
                .HasMaxLength(64)
                .HasColumnName("message_id");
        });

        modelBuilder.Entity<MessageRecv>(entity =>
        {
            entity.HasKey(e => e.MessageId).HasName("PRIMARY");

            entity.ToTable("message_recv");

            entity.Property(e => e.MessageId)
                .HasMaxLength(64)
                .HasColumnName("message_id");
            entity.Property(e => e.Body).HasColumnName("body");
            entity.Property(e => e.GroupName)
                .HasMaxLength(50)
                .HasColumnName("group_name");
            entity.Property(e => e.HasRead).HasColumnName("has_read");
            entity.Property(e => e.OwnerId)
                .HasMaxLength(50)
                .HasColumnName("owner_id");
            entity.Property(e => e.ReceiveTime)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("timestamp")
                .HasColumnName("receive_time");
            entity.Property(e => e.SenderId)
                .HasMaxLength(50)
                .HasColumnName("sender_id");
            entity.Property(e => e.SenderName)
                .HasMaxLength(50)
                .HasColumnName("sender_name");
            entity.Property(e => e.Title)
                .HasMaxLength(100)
                .HasColumnName("title");
        });

        modelBuilder.Entity<MessageSent>(entity =>
        {
            entity.HasKey(e => e.MessageId).HasName("PRIMARY");

            entity.ToTable("message_sent");

            entity.Property(e => e.MessageId)
                .HasMaxLength(64)
                .HasColumnName("message_id");
            entity.Property(e => e.Body).HasColumnName("body");
            entity.Property(e => e.Data).HasColumnName("data");
            entity.Property(e => e.GroupName)
                .HasMaxLength(50)
                .HasColumnName("group_name");
            entity.Property(e => e.ReceiverId)
                .HasMaxLength(50)
                .HasColumnName("receiver_id");
            entity.Property(e => e.ReceiverName)
                .HasMaxLength(50)
                .HasColumnName("receiver_name");
            entity.Property(e => e.SendTime)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("timestamp")
                .HasColumnName("send_time");
            entity.Property(e => e.SenderId)
                .HasMaxLength(50)
                .HasColumnName("sender_id");
            entity.Property(e => e.SenderName)
                .HasMaxLength(50)
                .HasColumnName("sender_name");
            entity.Property(e => e.TemplateName)
                .HasMaxLength(50)
                .HasColumnName("template_name");
            entity.Property(e => e.Title)
                .HasMaxLength(50)
                .HasColumnName("title");
        });

        modelBuilder.Entity<WechatSent>(entity =>
        {
            entity.HasKey(e => e.MessageId).HasName("PRIMARY");

            entity.ToTable("wechat_sent");

            entity.Property(e => e.MessageId)
                .HasMaxLength(50)
                .HasColumnName("message_id");
            entity.Property(e => e.AccountName)
                .HasMaxLength(50)
                .HasColumnName("account_name");
            entity.Property(e => e.Body).HasColumnName("body");
            entity.Property(e => e.Data).HasColumnName("data");
            entity.Property(e => e.PictureUrl)
                .HasMaxLength(2048)
                .HasColumnName("picture_url");
            entity.Property(e => e.Receiver)
                .HasMaxLength(500)
                .HasColumnName("receiver");
            entity.Property(e => e.Response).HasColumnName("response");
            entity.Property(e => e.SendTime)
                .HasDefaultValueSql("CURRENT_TIMESTAMP")
                .HasColumnType("timestamp")
                .HasColumnName("send_time");
            entity.Property(e => e.TemplateName)
                .HasMaxLength(50)
                .HasColumnName("template_name");
            entity.Property(e => e.Title)
                .HasMaxLength(100)
                .HasColumnName("title");
            entity.Property(e => e.Url)
                .HasMaxLength(2048)
                .HasColumnName("url");
        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
